package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.article.dtos.ArticleInfoDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jack
 * @data 2024 11:47
 */
@RestController
@RequestMapping("/api/v1/article")
public class ApArticleController {

    @Autowired
    private ApArticleService apArticleService;


    /**
     * app首页文章列表 -- 加载首页
     * @param homeDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto homeDto){
        return apArticleService.load1(homeDto,1);
    }

    /**
     * app首页文章列表 -- 加载更新
     * @param homeDto
     * @return
     */
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto homeDto){
        return apArticleService.load(homeDto,2);
    }

    /**
     * app首页文章列表 -- 加载更多
     * @param homeDto
     * @return
     */
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto homeDto){
        return apArticleService.load(homeDto,1);
    }

    /**
     * @author 18297
     * @date 2024/1/26 14:37
     * @description 加载文章行为数据回显
     * @param :
     * @return ResponseResult<?>
     */
    @PostMapping("/load_article_behavior")
    public ResponseResult<?> loadArticleBehavior(@RequestBody ArticleInfoDto dto){
        return apArticleService.loadArticleBehavior(dto);
    }
}
